package com.ncloud.resman.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.ncloud.resman.entity.DeviceIp;
import com.ncloud.resman.entity.ExportFire;
import com.ncloud.resman.mapper.DeviceIpMapper;
import com.ncloud.resman.service.DeviceIpService;
import com.ncloud.resman.service.SequenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by shiqiang on 2017/8/15.
 */
@Service
public class DeviceIpServiceImpl implements DeviceIpService{
    @Autowired
    private DeviceIpMapper deviceIpMapper;
    @Autowired
    private SequenceService sequenceService;

    @Override
    public int insertDeviceIp(DeviceIp deviceIp) {
        if(deviceIp.getId()== null){
            Long id = sequenceService.getSequence("ip_id_seq");
            deviceIp.setId(id);
        }
        deviceIp.setUseTag("1");
        return deviceIpMapper.insertDeviceIp(deviceIp);
    }

    @Override
    public int deleteDeviceIp(Long deviceId) {
        return deviceIpMapper.deleteDeviceIp(deviceId);
    }

    @Override
    public List<JSONObject> getDeviceIpById(Long deviceId) {
        return deviceIpMapper.getDeviceIpById(deviceId);
    }

	@Override
	public List<DeviceIp> getDeviceIpBySnNum(String snNum) {
		return deviceIpMapper.getDeviceIpBySnNum(snNum);
	}

}
